<template>
  <div class="wrap">
    <div class="load g-flex-column-c" v-if="loading">
      <img :src="gifUrl" alt="">
      <div class="progress-box">
        <div class="progress-bar" :style="{width: width+'%'}"></div>
        <div class="progress-num">{{width}}%</div>
      </div>
    </div>
    <div class="success" v-else>
      <div><img class="img" :src="ossUrl+'market/success.gif'" alt=""></div>
      <div>活动发起成功</div>
      <div>一大波司机即将来到，请做好准备迎接吧</div>
      <div>
        <el-button @click="gotoList">查看活动列表</el-button>
        <el-button type="primary" @click="gotoHelper">返回能＋小助手</el-button>
      </div>
    </div>
  </div>
</template>
<script>
import { ossUrl }  from '@/utils/config'
export default {
  data() {
    return {
      loading: false,
      ossUrl,
      gifUrl: `${ossUrl}market/loading.gif`,
      width: 20,
    }
  },
  mounted () {
    this.initPage()
  },
  methods: {
    initPage(){
      const { isLoading } = this.$route.query
      if(isLoading){
        this.loading = true
        let clearId = setInterval(()=>{
          this.width += 20
        },950)
        setTimeout(() => {
          clearInterval(clearId);
          this.loading = false
        }, 4600)
      }
    },
    gotoHelper () {
      this.$router.push({ path: '/marketCenter/marketHelper' })
    },
    gotoList () {
      this.$router.push({ path: '/dataAnalyze/dataAnalyze_index' })
    }
  }
}
</script>

<style scoped lang="less">
.wrap{
  position: absolute;
  top:65px;
  left:10px;
  bottom: 10px;
  right: 10px;
  background: #fff;
  display: flex;
  justify-content: center;
  align-content: center;
}
.load{
  width: 100%;
  background: #fff;
  >img{
    display: block;
    width: 360px;
    height: 360px;
    margin-bottom: 81px;
  }
}
.success{
  width: 100%;
  height: 635px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  div:nth-child(1){
    margin-bottom: 20px;
  }
  div:nth-child(2){
    margin-bottom: 50px;
  }
  div:nth-child(3){
    margin-bottom: 50px;
    font-size: 16px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
  }
  .img{
    display: block;
    width: 240px;
    height: 148px;
  }
}
.el-button{
  width: 180px;
}
.progress-box{
  width: 294px;
  height: 14px;
  background: #E5ECFF;
  border-radius: 12px;
  .progress-bar{
    width: 20px;
    height: 14px;
    background: #4376FF;
    border-radius: 12px;
  }
  .progress-num{
    text-align: center;
    margin-top: 5px;
    font-size: 24px;
    font-weight: 500;
    color: #4376FF;
  }
}

</style>